require(["dojo/dom", "dojo/_base/window", "dijit/_WidgetBase", "dijit/_TemplatedMixin", 
    "dojo/json", "dojo/request", "dijit/registry", "dojox/grid/DataGrid", 
    "dojo/data/ItemFileWriteStore", "dojo/parser"], 
        function(dom, win, _WidgetBase, _TemplatedMixin, JSON, request, registry, 
            DataGrid, ItemFileWriteStore, parser) {
            
            declare("Table", [_WidgetBase, _TemplatedMixin], {

                templateString:
                    "<div data-dojo-type='DataGrid' id='grid' ></div>",

                sql: "",

                update: function() {
                    request.post("tables", {
                        handleAs: "json"}).then(function(data) {
                            dataStore = new ItemFileWriteStore(data);
                            registry.byId('grid').setStore(dataStore);
                        });
                }
            });

            ready(function() {
                parser.parse();
            });
        }
);
